<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/mytag.jspf"%>

<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>user</title>
<script type="text/javascript">
var cols = new Array();
cols[0] = "会员卡号";
cols[1] = "姓名";
cols[2] = "性别";
cols[3] = "生日";
cols[4] = "手机号";
cols[5] = "积分";
				
cols[6] = "余额";
cols[7] = "身份证号";
cols[8] = "操作";
var mods = new Array();
mods[0]={name:"vipNo", width:30};
mods[1] = {name:"name",width:30};
mods[2] = {name:"sex",width:20,formatter: "select", editoptions:{value:"M:男;F:女"}};
mods[3] = {name:"birthday",width:60,formatter:"date", formatoptions: {newformat:'Y-m-d'}};
mods[4] ={name:"phoneNo",width:40};
mods[5] ={name:"points",width:20};
mods[6] ={name:"balance",width:20};
mods[7] ={name:"idNo",width:50};
mods[8] ={name:"ctrl",width:50,formatter:function(cellvalue, options, rowObject){
		var btns = "<div class='am-btn-group am-btn-group-xs'>";
			btns+="<a href='management/vip/edit/"+rowObject.vipId+"' class='am-btn am-btn-default' title='修改'><span class='am-icon-edit'></span>修改</a>";
			if(rowObject.isStar=="YES"){
				btns+="<button type='button' class='am-btn am-btn-default' title='标星' onclick='setSatr(\""+rowObject.vipId+"\",\""+rowObject.isStar+"\")'><span class='am-icon-star admin-icon-yellow'></span> 标星</button>";
			}else{
				btns+="<button type='button' class='am-btn am-btn-default' title='标星' onclick='setSatr(\""+rowObject.vipId+"\",\""+rowObject.isStar+"\")'><span class='am-icon-star'></span> 标星</button>";
			}
			
			//btns+="<button type='button' class='am-btn am-btn-default' title='删除' onclick='delRow(\""+rowObject.vipId+"\")'><span class='am-icon-trash'></span> 删除</button>";
			btns+="</div>";
			return btns;
		}};
$("#grid").jqGrid({
		pager:"#pager",
		url:"management/vip/page",
	   	colNames:cols,
	   	colModel:mods
	});
	$(function(){ 
	    $("#searchBtn").click(function(){
	        $("#grid").jqGrid('setGridParam',{ 
	            postData:$("#queryForm").serializeJson(), //发送数据
	            page:1
	        }).trigger("reloadGrid"); //重新载入 
	    }); 
	});	
	function setSatr(id,isStar){
		var msg = "是否标星？";
		if (id == "") {
			layer.msg("请选择标星项！！");
			return;
		}
		if(isStar=="YES"){
			msg="是否取消标星?";
			isStar="NO";
		}else{
			isStar="YES";
		}
		layer.confirm(msg, function(index) {
			var url = "management/vip/setstar/"+id+"/"+isStar;
			$.ajax({
				type : 'POST',
				url : url,
				dataType : 'json',
				success : function(data) {
					layer.msg(data.msg);
					if (data.success) {
						$("#grid").jqGrid().trigger("reloadGrid"); //重新载入 
					}
				}
			});
		});
	}
	function delRow(id){
		if (id == "") {
			layer.msg("请选择删除项！！");
			return;
		}
		layer.confirm('是否删除？', function(index) {
			var url = "management/vip/delete/"+id;
			$.ajax({
				type : 'POST',
				url : url,
				dataType : 'json',
				success : function(data) {
					layer.msg(data.msg);
					if (data.success) {
						$("#grid").jqGrid().trigger("reloadGrid"); //重新载入 
					}
				}
			});
		});
	}
</script>
</head>

<body>
	<ol class="am-breadcrumb am-breadcrumb-slash am-padding" style="margin-bottom: 0px;">
		<li><a href="management/index">首页</a></li>
		<li class="am-active">会员档案管理</li>
	</ol>

	<div class="am-g">
		<div class="am-u-md-8">
			<div class="am-btn-toolbar">
				<div class="am-btn-group am-btn-group-sm">
					<a href="management/vip/add" class="am-btn am-btn-default"><span class="am-icon-plus"></span> 新增</a>
				</div>
			</div>
		</div>
		<form id="queryForm">
		<div class="am-u-md-4">
			<div class="am-input-group am-input-group-sm">
				<input type="text" name="vipNo" class="am-form-field" placeholder="请输入会员号查询"><span class="am-input-group-btn"><button class="am-btn am-btn-default" type="button" id="searchBtn">搜索</button></span>
			</div>
		</div>
		</form>
	</div>
	<div class="am-g am-padding-vertical">
		<div class="am-u-md-12"><table id="grid"></table><div id="pager"></div></div>
	</div>
</body>
</html>
